package com.xindacloud.sms.console.system.service.impl;

import org.springframework.stereotype.Service;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.xindacloud.sms.console.result.Result;
import com.xindacloud.sms.console.result.ResultGenerator;
import com.xindacloud.sms.console.system.dto.SmsWebsiteDTO;
import com.xindacloud.sms.console.system.entity.SmsWebsiteInfo;
import com.xindacloud.sms.console.system.mapper.SmsWebsiteInfoMapper;
import com.xindacloud.sms.console.system.service.ISmsWebsiteInfoService;

/**
 * <p>
 *  服务实现类
 * </p>
 *
 * @author czc
 * @since 2019-10-14
 */
@Service
public class SmsWebsiteInfoServiceImpl extends ServiceImpl<SmsWebsiteInfoMapper, SmsWebsiteInfo> implements ISmsWebsiteInfoService {

	@Override
	public Result getSmsWebsiteInfo(SmsWebsiteDTO smsWebsiteDTO) {
		QueryWrapper<SmsWebsiteInfo> queryWrapper=new QueryWrapper<>();
		if(smsWebsiteDTO.getId()!=null) {
		queryWrapper.eq("id", smsWebsiteDTO.getId());
		SmsWebsiteInfo smsWebsiteInfo=this.getOne(queryWrapper);
		return ResultGenerator.genSuccessResult(smsWebsiteInfo);
		}else {
			return ResultGenerator.genClientFailResult("错误！请输入id！！！");
		}
		
	}

	@Override
	public Result saveOrUpdateSmsWebsiteInfo(SmsWebsiteInfo smsWebsiteInfo) {
		if(this.saveOrUpdate(smsWebsiteInfo)){
		    return ResultGenerator.genSuccessResult("保存或修改成功！");
		}else {
			return ResultGenerator.genClientFailResult("保存或修改失败！");
		}
	}

}
